//
//  SKView+Push.m
//  MagicSword
//
//  Created by Netease on 15/12/9.
//  Copyright © 2015年 Jonear. All rights reserved.
//

#import "SKView+Push.h"

static NSMutableArray *sceneArray = nil;

@implementation SKView (Push)

- (void)pushScene:(SKScene *)scene {
    if (scene == nil || ![scene isKindOfClass:[SKScene class]]) {
        return;
    }
    
    if (!sceneArray) {
        sceneArray = [NSMutableArray array];
    }
    [sceneArray addObject:scene];
    [self presentScene:scene];
}

- (void)popScene {
    if (sceneArray.count > 1) {
        [sceneArray removeObjectAtIndex:sceneArray.count-1];
        [self presentScene:[sceneArray lastObject]];
    }
}

- (NSArray *)sceneArray {
    return sceneArray;
}

@end
